#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive

if [[ $1 == "" ]];then
   db=zx_dwd
else
   db=$1
fi

${HIVE_HOME} -S -e "


INSERT OVERWRITE  TABLE dwd_visit_consult.web_chat_text_ems_2019_07
SELECT id,
       referrer,
       from_url,
       landing_page_url,
       url_title,
       platform_description,
       other_params,
       history
FROM visit_consult.web_chat_text_ems_2019_07;

INSERT OVERWRITE  TABLE dwd_visit_consult.web_chat_ems_2019_17
SELECT
       id,
       create_date_time,
       year(create_date_time) AS `year`, --年
       quarter(create_date_time) as `quarter`, --季度
      month(create_date_time) AS  `month`, -- 月
      to_date(create_date_time) as `day`, --天
       session_id,
       sid,
       create_time,
       seo_source,
       seo_keywords,
       ip,
       area,
       country,
       province,
       city,
       origin_channel,
       `user`,
       manual_time,
       begin_time,
       end_time,
       last_customer_msg_time_stamp,
       last_agent_msg_time_stamp,
       reply_msg_count,
       msg_count,
       browser_name,
       os_info
FROM visit_consult.web_chat_ems_2019_17;



"